package com.itcrm.baiduai;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.itcrm.baiduai.net.Api;
import com.itcrm.baiduai.net.NetUtils;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class IndexActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);

        OkHttpClient client = new OkHttpClient();
        final Request request = new Request.Builder().url(Api.GET_AUTH_PREFIX +
                "grant_type=client_credentials" + "&client_id=" + Api.APP_KEY +
                "&client_secret=" + Api.SECRET_KEY).build();
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                System.out.println("-->" + response.body().string());
            }
        });
    }
}